import { createWebHistory, createRouter } from 'vue-router'
import Home from '@/pages/Home/home.vue'
import Register from '@/pages/Register/register.vue'
import Department from '@/pages/Register/Department.vue'
import Pay from '@/pages/Pay/pay.vue'
import User from '@/pages/UserInfo/userinfo.vue'
import Disgnosis from '@/pages/Diagnosis/diagnosis.vue'
import ChatAI from '@/pages/Diagnosis/Chat/ChatAI.vue'
import ChatDoc from '@/pages/Diagnosis/Chat/ChatDoc.vue'
import Consultation from '@/pages/Diagnosis/Consultation/consultation.vue'
import Success from '@/pages/Pay/success/success.vue'
import Doctor from '@/pages/Doctor/doctor.vue'
import ChatUser from '@/pages/Doctor/Chat/ChatUser.vue'
import ShowDoc from '@/pages/Diagnosis/ShowDoc/ShowDoc.vue'
import ShowUser from '@/pages/Doctor/Chat/ShowUser.vue'
import userLogin from '@/pages/Home/userLoin/userLogin.vue'
import userReg from '@/pages/Home/userReg/userReg.vue'
import userReset from '@/pages/Home/userReset/userReset.vue'
import record from '@/pages/UserInfo/records/record.vue'

export default createRouter({
  history:createWebHistory(),
  routes:[
    {
      path:'/',
      redirect:'/home'
    },
    {
      path:'/home',
      component:Home,
    
    },
    {
      path:'/login',
      component:userLogin
    },
    {
      path:'/reg',
      component:userReg
    },
    {
      path:'/reset',
      component:userReset
    },
    {
      path:'/register',
      component:Register,
    },
    {
      path:'/department',
      component:Department
    },
    {
      path:'/pay',
      component:Pay
    },
    {
      path:'/user',
      component:User
    },
    {
      path:'/diagnosis',
      component:Disgnosis,
    },
    {
      path:'/chat',
      component:ChatAI
    },
    {
      path:'/chatdoc',
      component:ChatDoc
    },
    {
      path:'/success',
      component:Success
    },
    {
      path:'/consultation',
      component:Consultation
    },
    {
      path:'/doctor',
      component:Doctor
    },
    {
      path:'/chatuser',
      component:ChatUser
    },
    {
      path:'/showdoc',
      component:ShowDoc
    },
    {
      path:'/showuser',
      component:ShowUser
    },
    {
      path:'/record',
      component:record
    }
  ],
  scrollBehavior(to, from, savedPosition) {
    // 如果路由有 hash，滚动到对应元素
    if (to.hash) {
      return {
        el: to.hash,
        behavior: 'smooth', // 可选：平滑滚动
      };
    }
    // 否则滚动到顶部
    return { top: 0 };
  },
})